﻿using SmartSapce.ServiceLocation;
using SmartSpace.Core;
using SmartSpace.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.WebApp._console.page
{
    public partial class page_add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }
        }

        protected void _ctlBtnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(_ctlSelTemplateId.Value))
            {
                VirtualPage page = new VirtualPage();
                page.Id = Guid.NewGuid();
                page.AppId = SsSite.Current.Id;
                page.Code = _ctlEditName.Text;
                page.Caption = _ctlEditCaption.Text;
                page.TemplateId = new Guid(_ctlSelTemplateId.Value);

                ICoreService service = ServiceLocator.Get<ICoreService>();
                if (service.SavePage(page))
                {
                    Response.Redirect("./page-list.aspx");
                }
            }
        }
    }
}